package gui.panel;

import enums.ExtensionEnum;
import enums.PremisaTypeEnum;
import j_util.Utiles;
import model.Premisa;
import model.Sylogism;

import javax.swing.*;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/*

    This file is part of Logica-Logike.

    Logica-Logike is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation version 3 of the License.

    Logica-Logike is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Logica-Logike.  If not, see <http://www.gnu.org/licenses/>.

 */
/**
 * Extension de JPanel, referido a la funcionalidad y visualizacion de silogismo.
 * Codigo poco mantenible, se considera su eliminacion en algun momento;
 *  @author Jose Martin Rozanec;
 * @deprecated;
 */
public class SilogismoPanel extends JPanel {
    private javax.swing.JButton analizarButton;
    private javax.swing.JPanel bottomPanel;
    private javax.swing.JComboBox combo1;
    private javax.swing.JComboBox combo2;
    private javax.swing.JComboBox combo3;
    private javax.swing.JButton completarButton;
    private javax.swing.JTextField conclusionField;
    private javax.swing.JLabel conclusionLabel;
    private javax.swing.JLabel convertirEnLabel;
    private javax.swing.JPanel cuadroPanel;
    private javax.swing.JLabel figuraLabel;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JTextField premisaMayorField;
    private javax.swing.JLabel premisaMayorLabel;
    private javax.swing.JTextField premisaMenorField;
    private javax.swing.JLabel premisaMenorLabel;
    private javax.swing.JButton resetearButton;
    private javax.swing.JLabel terminoMayorLabel;
    private javax.swing.JLabel terminoMedioLabel;
    private javax.swing.JLabel terminoMenorLabel;
    private javax.swing.JTextArea textArea;

    private Sylogism sylogism;

    public SilogismoPanel() {
        this.sylogism = new Sylogism();
        initComponents();
    }

    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        cuadroPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        premisaMayorField = new javax.swing.JTextField();
        premisaMayorLabel = new javax.swing.JLabel();
        convertirEnLabel = new javax.swing.JLabel();
        combo1 = new javax.swing.JComboBox();
        premisaMenorLabel = new javax.swing.JLabel();
        premisaMenorField = new javax.swing.JTextField();
        combo2 = new javax.swing.JComboBox();
        jSeparator1 = new javax.swing.JSeparator();
        conclusionLabel = new javax.swing.JLabel();
        conclusionField = new javax.swing.JTextField();
        combo3 = new javax.swing.JComboBox();
        completarButton = new javax.swing.JButton();
        analizarButton = new javax.swing.JButton();
        resetearButton = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        figuraLabel = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        terminoMayorLabel = new javax.swing.JLabel();
        terminoMedioLabel = new javax.swing.JLabel();
        terminoMenorLabel = new javax.swing.JLabel();
        bottomPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        textArea = new javax.swing.JTextArea();

        mainPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true), "Silogismo"));

        cuadroPanel.setBackground(new java.awt.Color(255, 255, 255));
        cuadroPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true), "Silogismo"));

        premisaMayorField.addCaretListener(new CaretListener() {
            public void caretUpdate(CaretEvent e) {
                if (Premisa.isComplete(premisaMayorField.getText())) {
                    sylogism.setPremisa(new Premisa(premisaMayorField.getText()), PremisaTypeEnum.FIRST);
                    premisaMayorField.setForeground(new Color(0, 0, 0));
                    setPropertiesOrSuggestions();
                } else {
                    sylogism.setPremisa(null, PremisaTypeEnum.FIRST);
                    premisaMayorField.setForeground(new Color(255, 0, 0));
                    setPropertiesOrSuggestions();
                }
            }
        });

        premisaMenorField.addCaretListener(new CaretListener() {
            public void caretUpdate(CaretEvent e) {
                if (Premisa.isComplete(premisaMenorField.getText())) {
                    sylogism.setPremisa(new Premisa(premisaMenorField.getText()), PremisaTypeEnum.SECOND);
                    premisaMenorField.setForeground(new Color(0, 0, 0));
                    setPropertiesOrSuggestions();
                } else {
                    sylogism.setPremisa(null, PremisaTypeEnum.SECOND);
                    premisaMenorField.setForeground(new Color(255, 0, 0));
                    setPropertiesOrSuggestions();
                }
            }
        });

        conclusionField.addCaretListener(new CaretListener() {
            public void caretUpdate(CaretEvent e) {
                if (Premisa.isComplete(conclusionField.getText())) {
                    sylogism.setPremisa(new Premisa(conclusionField.getText()), PremisaTypeEnum.CONCLUSION);
                    conclusionField.setForeground(new Color(0, 0, 0));
                    setPropertiesOrSuggestions();
                } else {
                    sylogism.setPremisa(null, PremisaTypeEnum.CONCLUSION);
                    conclusionField.setForeground(new Color(255, 0, 0));
                    setPropertiesOrSuggestions();
                }
            }
        });

        premisaMayorLabel.setText("Premisa mayor");

        convertirEnLabel.setText("Convertir en");

        combo1.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"A", "E", "I", "O"}));
        combo1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                comboConvertOrComplete(PremisaTypeEnum.FIRST, combo1.getSelectedIndex());
            }
        });

        premisaMenorLabel.setText("Premisa menor");

        combo2.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"A", "E", "I", "O"}));
        combo2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                comboConvertOrComplete(PremisaTypeEnum.FIRST, combo2.getSelectedIndex());
            }
        });

        jSeparator1.setForeground(new java.awt.Color(0, 0, 0));

        conclusionLabel.setText("Conclusion");

        combo3.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"A", "E", "I", "O"}));
        combo3.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                comboConvertOrComplete(PremisaTypeEnum.CONCLUSION, combo3.getSelectedIndex());
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(conclusionLabel)
                                .addContainerGap())
                        .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(premisaMenorLabel)
                                .addContainerGap())
                        .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(premisaMayorLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 437, Short.MAX_VALUE)
                                .addComponent(convertirEnLabel)
                                .addGap(34, 34, 34))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(conclusionField, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(premisaMenorField, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(premisaMayorField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 492, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(combo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(combo2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(combo3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(35, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(premisaMayorLabel)
                                .addComponent(convertirEnLabel))
                        .addGap(5, 5, 5)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(premisaMayorField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(combo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(premisaMenorLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(premisaMenorField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(combo2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(conclusionLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(conclusionField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(combo3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(27, Short.MAX_VALUE))
        );

        completarButton.setText("Completar");
        completarButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                sylogism.complete();
                setSylogism(sylogism);
            }
        });

        analizarButton.setText("Analizar");
        analizarButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                analize();
            }
        });

        resetearButton.setText("Resetear");
        resetearButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                reset();
            }
        });


        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true), "Figura"));

        figuraLabel.setIcon(Utiles.createImageIcon("/gui/images/figura/NONE.png"));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(figuraLabel)
                        .addContainerGap(21, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(figuraLabel)
                        .addContainerGap(20, Short.MAX_VALUE))
        );

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true), "Terminos"));

        terminoMayorLabel.setText("Termino mayor:");

        terminoMedioLabel.setText("Termino medio:");

        terminoMenorLabel.setText("Termino menor:");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(terminoMayorLabel)
                                .addComponent(terminoMenorLabel)
                                .addComponent(terminoMedioLabel))
                        .addContainerGap(313, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
                jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(terminoMayorLabel)
                        .addGap(36, 36, 36)
                        .addComponent(terminoMedioLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE)
                        .addComponent(terminoMenorLabel)
                        .addGap(26, 26, 26))
        );

        javax.swing.GroupLayout cuadroPanelLayout = new javax.swing.GroupLayout(cuadroPanel);
        cuadroPanel.setLayout(cuadroPanelLayout);
        cuadroPanelLayout.setHorizontalGroup(
                cuadroPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(cuadroPanelLayout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap())
                        .addGroup(cuadroPanelLayout.createSequentialGroup()
                                .addGap(43, 43, 43)
                                .addComponent(completarButton)
                                .addGap(152, 152, 152)
                                .addComponent(analizarButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 186, Short.MAX_VALUE)
                                .addComponent(resetearButton)
                                .addGap(52, 52, 52))
                        .addGroup(cuadroPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
        );
        cuadroPanelLayout.setVerticalGroup(
                cuadroPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(cuadroPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(cuadroPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(completarButton)
                                .addComponent(analizarButton)
                                .addComponent(resetearButton))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(cuadroPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
                mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(mainPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(cuadroPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 665, Short.MAX_VALUE)
                        .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
                mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(cuadroPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        bottomPanel.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true), "Teoria"), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)));

        textArea.setColumns(20);
        textArea.setEditable(false);
        textArea.setRows(5);
        jScrollPane1.setViewportView(textArea);

        javax.swing.GroupLayout bottomPanelLayout = new javax.swing.GroupLayout(bottomPanel);
        bottomPanel.setLayout(bottomPanelLayout);
        bottomPanelLayout.setHorizontalGroup(
                bottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 681, Short.MAX_VALUE)
        );
        bottomPanelLayout.setVerticalGroup(
                bottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(bottomPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(mainPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
        );
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                        .addComponent(mainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(bottomPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
        );

        bottomPanel.getAccessibleContext().setAccessibleName("Analisis");

    }

    private void setPropertiesOrSuggestions() {
        switch (sylogism.getFigure()) {
            case FIRST:
                figuraLabel.setIcon(Utiles.createImageIcon("/gui/images/figura/Figura1.png"));
                break;
            case SECOND:
                figuraLabel.setIcon(Utiles.createImageIcon("/gui/images/figura/Figura2.png"));
                break;
            case THIRD:
                figuraLabel.setIcon(Utiles.createImageIcon("/gui/images/figura/Figura3.png"));
                break;
            case FOURTH:
                figuraLabel.setIcon(Utiles.createImageIcon("/gui/images/figura/Figura4.png"));
                break;
            default:
                figuraLabel.setIcon(Utiles.createImageIcon("/gui/images/figura/NONE.png"));
                break;
        }
        textArea.setText(sylogism.getPremisaSuggestion());
        terminoMayorLabel.setText("Termino mayor: " + sylogism.getTerminoMayor());
        terminoMedioLabel.setText("Termino medio: " + sylogism.getTerminoMedio());
        terminoMenorLabel.setText("Termino menor: " + sylogism.getTerminoMenor());
        manageCompleteButton();
    }

    private void analize() {
        textArea.setText(sylogism.analize());
        //todo agregar las extensiones de los terminos...
    }

    private void reset() {
        sylogism.setPremisa(null, PremisaTypeEnum.FIRST);
        sylogism.setPremisa(null, PremisaTypeEnum.SECOND);
        sylogism.setPremisa(null, PremisaTypeEnum.CONCLUSION);
        premisaMayorField.setText("");
        premisaMenorField.setText("");
        conclusionField.setText("");
        setPropertiesOrSuggestions();
    }

    public void comboConvertOrComplete(PremisaTypeEnum premisaTypeEnum, int selectedIndex) {
        if (sylogism.getPremisa(premisaTypeEnum) != null) {
            switch (selectedIndex) {
                case 0://A
                    sylogism.getPremisa(premisaTypeEnum).convert(ExtensionEnum.A);
                    break;
                case 1://E
                    sylogism.getPremisa(premisaTypeEnum).convert(ExtensionEnum.E);
                    break;
                case 2://I
                    sylogism.getPremisa(premisaTypeEnum).convert(ExtensionEnum.I);
                    break;
                case 3://O
                    sylogism.getPremisa(premisaTypeEnum).convert(ExtensionEnum.O);
                    break;
                case 4://todo getRandomPremisa
                    break;
            }
            switch (premisaTypeEnum) {
                case FIRST:
                    premisaMayorField.setText(sylogism.getPremisa(premisaTypeEnum).toString());
                    break;
                case SECOND:
                    premisaMenorField.setText(sylogism.getPremisa(premisaTypeEnum).toString());
                    break;
                case CONCLUSION:
                    conclusionField.setText(sylogism.getPremisa(premisaTypeEnum).toString());
                    break;
            }
        }
        setPropertiesOrSuggestions();
    }

    public void setSylogism(Sylogism sylogism) {
        this.sylogism = sylogism;
        if (sylogism.getPremisa(PremisaTypeEnum.FIRST) != null) {
            premisaMayorField.setText(sylogism.getPremisa(PremisaTypeEnum.FIRST).toString());
        }
        if (sylogism.getPremisa(PremisaTypeEnum.SECOND) != null) {
            premisaMenorField.setText(sylogism.getPremisa(PremisaTypeEnum.SECOND).toString());
        }
        if (sylogism.getPremisa(PremisaTypeEnum.CONCLUSION) != null) {
            conclusionField.setText(sylogism.getPremisa(PremisaTypeEnum.CONCLUSION).toString());
        }
        setPropertiesOrSuggestions();
        analize();
    }

    private void manageCompleteButton() {
        int i = 0;
        if (!sylogism.getTerminoMayor().equals("")) {
            i++;
        }
        if (!sylogism.getTerminoMedio().equals("")) {
            i++;
        }
        if (!sylogism.getTerminoMenor().equals("")) {
            i++;
        }
        if (i >= 2) {
            completarButton.setEnabled(true);
        } else {
            completarButton.setEnabled(false);
        }
    }
}
